﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace ExtendBLL
{
    public class Class:LabMS.BLL.Class
    {
        /// <summary>
        /// 根据专业ID查找出专业名称
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public string ProessionalNameByID(int ID)
        {
            string str = "ID="+ID;
            LabMS.BLL.Professional BP = new LabMS.BLL.Professional();
            string Pro_Name = BP.GetModelList(str)[0].Pro_Name;
            return Pro_Name;
        }

        public DataSet GetListByStr()
        {
            string str = "select ID,Class_Code,Class_Name,Class_Year,Class_StudentNum,(select Pro_Name from Professional where Class.Class_Professional=Professional.ID) as Class_Professional from Class";
            DataSet ds = new DataSet();
            ds=Maticsoft.DBUtility.DbHelperSQL.Query(str);
            return ds;
        }

        /// <summary>
        /// 班级编号是否存在
        /// </summary>
        /// <param name="Class"></param>
        /// <returns></returns>
        public int IsExistClass(string strClass)
        {
            string str = "Class_Code='"+strClass+"'";
            LabMS.BLL.Class BC = new LabMS.BLL.Class();
            if (BC.GetModelList(str).Count > 0)
            {
                //已经存在
                return 1;
            }
            else
            {
                //不存在，可以保存
                return 0;
            }
        }

        /// <summary>
        /// 根据班级号查出班级名称
        /// </summary>
        /// <param name="ClassID"></param>
        /// <returns></returns>
        public string GetClassNameByClassID(int ClassID)
        {
            string str = "ID="+ClassID;
            LabMS.BLL.Class BClass=new LabMS.BLL.Class();
            string Class_Name = BClass.GetModelList(str)[0].Class_Name;
            return Class_Name;
        }

        /// <summary>
        /// 根据课程安排信息 查询选课班级信息
        /// </summary>
        /// <param name="Week"></param>
        /// <param name="WeekDay"></param>
        /// <param name="Lession"></param>
        /// <param name="LocationID"></param>
        /// <returns></returns>
        public DataSet GetClassInfoByArrangement(string Week, int WeekDay, int Lession, int LocationID)
        {
            string sql="select * from Class where [ID] in (select distinct ClassID from Arrangement where [Week]='"+Week+"' and [WeekDay]="+WeekDay+" and Lession=" +Lession+" and LocationID="+LocationID+")";
            DataSet ds = new DataSet();

            return Maticsoft.DBUtility.DbHelperSQL.Query(sql);
        }
    }
}
